package com.ruitu.health_2.mvp.presenter;

import com.ruitu.arad.base.BasePresenter;
import com.ruitu.arad.util.ToastUtils;
import com.ruitu.health_2.mvp.model.ModelModel;
import com.ruitu.health_2.ui.activity.ChinaCulture2Activity;
import com.ruitu.health_2.ui.activity.ChinaCultureActivity;
import com.ruitu.health_2.ui.activity.CultureTravel2Activity;
import com.ruitu.health_2.ui.activity.EduCulture2Activity;
import com.ruitu.health_2.ui.activity.HealthManage2Activity;
import com.ruitu.health_2.ui.activity.HealthManageActivity;
import com.ruitu.health_2.ui.activity.LifeColorActivity;
import com.ruitu.health_2.ui.activity.ReadPartie2Activity;
import com.ruitu.health_2.ui.activity.ReadPartieActivity;
import com.ruitu.health_2.ui.activity.ReadPartieDetailActivity;
import com.ruitu.router_module.bean.BaseResult2;
import com.ruitu.router_module.bean.home.MallHomeData;
import com.ruitu.router_module.bean.home.ModelData;
import com.ruitu.router_module.bean.product.ReadPartyDetail;

import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

public class ModelPresenter {

    public static class ChinaCultureP extends BasePresenter<ChinaCultureActivity, ModelModel.ChinaCultureM> {

        public Disposable reqModelData(String modelId) {
            return m.reqModelData(modelId).subscribe(new Consumer<BaseResult2<ModelData>>() {
                @Override
                public void accept(BaseResult2<ModelData> modelResult) throws Exception {
                    v.hideProgress();
                    if (modelResult.isSuccess()) {
                        v.onReqComplete(1, true, modelResult.getData());
                    } else {
                        ToastUtils.showShortSafe(modelResult.getMessage());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    v.hideProgress();
                    throwable.printStackTrace();
                }
            });
        }
    }

    public static class ChinaCulture2P extends BasePresenter<ChinaCulture2Activity, ModelModel.ChinaCultureM> {
        public Disposable reqChinaCultureHomeData() {
            return m.reqChinaCultureHomeData().subscribe(new Consumer<BaseResult2<MallHomeData>>() {
                @Override
                public void accept(BaseResult2<MallHomeData> modelResult) throws Exception {
                    v.hideProgress();
                    if (modelResult.isSuccess()) {
                        v.onReqComplete(1, true, modelResult.getData());
                    } else {
                        ToastUtils.showShortSafe(modelResult.getMessage());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    v.hideProgress();
                    throwable.printStackTrace();
                }
            });
        }
    }

    public static class EduCulture2P extends BasePresenter<EduCulture2Activity, ModelModel.EduCultureM> {
        public Disposable reqEduCultureHomeData() {
            return m.reqEduCultureHomeData().subscribe(new Consumer<BaseResult2<MallHomeData>>() {
                @Override
                public void accept(BaseResult2<MallHomeData> modelResult) throws Exception {
                    v.hideProgress();
                    if (modelResult.isSuccess()) {
                        v.onReqComplete(1, true, modelResult.getData());
                    } else {
                        ToastUtils.showShortSafe(modelResult.getMessage());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    v.hideProgress();
                    throwable.printStackTrace();
                }
            });
        }
    }

    public static class CultureTravel2P extends BasePresenter<CultureTravel2Activity, ModelModel.CultureTravelM> {
        public Disposable reqCultureTravelHomeData() {
            return m.reqCultureTravelHomeData().subscribe(new Consumer<BaseResult2<MallHomeData>>() {
                @Override
                public void accept(BaseResult2<MallHomeData> modelResult) throws Exception {
                    v.hideProgress();
                    if (modelResult.isSuccess()) {
                        v.onReqComplete(1, true, modelResult.getData());
                    } else {
                        ToastUtils.showShortSafe(modelResult.getMessage());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    v.hideProgress();
                    throwable.printStackTrace();
                }
            });
        }
    }

    public static class ReadPartieP extends BasePresenter<ReadPartieActivity, ModelModel.ReadPartieM> {
        public Disposable reqModelData(String modelId) {
            return m.reqModelData(modelId).subscribe(new Consumer<BaseResult2<ModelData>>() {
                @Override
                public void accept(BaseResult2<ModelData> modelResult) throws Exception {
                    v.hideProgress();
                    if (modelResult.isSuccess()) {
                        v.onReqComplete(1, true, modelResult.getData());
                    } else {
                        ToastUtils.showShortSafe(modelResult.getMessage());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    v.hideProgress();
                    throwable.printStackTrace();
                }
            });
        }
    }

    public static class ReadPartie2P extends BasePresenter<ReadPartie2Activity, ModelModel.ReadPartieM> {
        public Disposable reqReadPartieHomeData() {
            return m.reqReadPartieHomeData().subscribe(new Consumer<BaseResult2<MallHomeData>>() {
                @Override
                public void accept(BaseResult2<MallHomeData> modelResult) throws Exception {
                    v.hideProgress();
                    if (modelResult.isSuccess()) {
                        v.onReqComplete(1, true, modelResult.getData());
                    } else {
                        ToastUtils.showShortSafe(modelResult.getMessage());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    v.hideProgress();
                    throwable.printStackTrace();
                }
            });
        }
    }

    public static class ReadPartieDetailP extends BasePresenter<ReadPartieDetailActivity, ModelModel.ReadPartieDetailM> {
        public Disposable reqReadPartieDetail(String id) {
            return m.reqReadPartieDetail(id).subscribe(new Consumer<BaseResult2<ReadPartyDetail>>() {
                @Override
                public void accept(BaseResult2<ReadPartyDetail> result) throws Exception {
                    v.hideProgress();
                    if (result.isSuccess()) {
                        v.onReqComplete(1, true, result.getData());
                    } else {
                        ToastUtils.showShortSafe(result.getMessage());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    v.hideProgress();
                    throwable.printStackTrace();
                }
            });
        }
    }

    public static class HealthManageP extends BasePresenter<HealthManageActivity, ModelModel.HealthManageM> {
        public Disposable reqModelData(String modelId) {
            return m.reqModelData(modelId).subscribe(new Consumer<BaseResult2<ModelData>>() {
                @Override
                public void accept(BaseResult2<ModelData> modelResult) throws Exception {
                    v.hideProgress();
                    if (modelResult.isSuccess()) {
                        v.onReqComplete(1, true, modelResult.getData());
                    } else {
                        ToastUtils.showShortSafe(modelResult.getMessage());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    v.hideProgress();
                    throwable.printStackTrace();
                }
            });
        }
    }

    public static class HealthManage2P extends BasePresenter<HealthManage2Activity, ModelModel.HealthManageM> {
        public Disposable reqHealthManageHomeData() {
            return m.reqHealthManageHomeData().subscribe(new Consumer<BaseResult2<MallHomeData>>() {
                @Override
                public void accept(BaseResult2<MallHomeData> modelResult) throws Exception {
                    v.hideProgress();
                    if (modelResult.isSuccess()) {
                        v.onReqComplete(1, true, modelResult.getData());
                    } else {
                        ToastUtils.showShortSafe(modelResult.getMessage());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    v.hideProgress();
                    throwable.printStackTrace();
                }
            });
        }
    }

    public static class LifeColor2P extends BasePresenter<LifeColorActivity, ModelModel.LifeColorM> {
        public Disposable reqLifeColorHomeData() {
            return m.reqLifeColorHomeData().subscribe(new Consumer<BaseResult2<MallHomeData>>() {
                @Override
                public void accept(BaseResult2<MallHomeData> modelResult) throws Exception {
                    v.hideProgress();
                    if (modelResult.isSuccess()) {
                        v.onReqComplete(1, true, modelResult.getData());
                    } else {
                        ToastUtils.showShortSafe(modelResult.getMessage());
                    }
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    v.hideProgress();
                    throwable.printStackTrace();
                }
            });
        }
    }
}
